package com.macro.mall.model_jpa;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Data
@Entity
@Table(name="cms_topic")
@DynamicInsert
public class CmsTopic implements Serializable {

    private static final long serialVersionUID = 1L;

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    @Column(name = "id")
    private Long id;

    @Column(name = "category_id")
    private Long categoryId;

    @Column(name = "name")
    private String name;

    @Column(name = "create_time")
    @CreatedDate
    private Date createTime;

    @Column(name = "start_time")
    private Date startTime;

    @Column(name = "end_time")
    private Date endTime;

    @ApiModelProperty(value = "参与人数")
    @Column(name = "attend_count")
    private Integer attendCount;

    @ApiModelProperty(value = "关注人数")
    @Column(name = "attention_count")
    private Integer attentionCount;

    @Column(name = "read_count")
    private Integer readCount;

    @ApiModelProperty(value = "奖品名称")
    @Column(name = "award_name")
    private String awardName;

    @ApiModelProperty(value = "参与方式")
    @Column(name = "attend_type")
    private String attendType;

    @ApiModelProperty(value = "话题内容")
    @Column(name = "content")
    private String content;

    @OneToMany(targetEntity = CmsHelp.class)
    @JoinColumn(name = "id", referencedColumnName = "topic_id")
    @JsonIgnore
    private Set<CmsTopicComment> topicCommentSet = new HashSet<>();

    @ManyToOne(targetEntity = CmsTopicCategory.class)
    @JoinColumn(name = "category_id", referencedColumnName = "id")
    private CmsTopicCategory topicCategory;
}